package com.example.yvque0312.dao;

import com.example.yvque0312.pojo.Article;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ArticleDao {
    //查双表
    List<Article> cha(Integer id);

    //查全表
    @Select("select * from article where create_user=#{id} and deleted=0")
    List<Article> chaquanbiao(Integer id);

    //假删除
    @Update("update article set deleted=1 where id=#{id}")
    int shanchu(Integer id);
    //添加
    @Update("insert into article(title,content,cover_img,state,category_id,create_user,create_time,update_time) values(#{title},#{content},#{cover_img},#{state},#{category_id},#{create_user},now(),now())")
    int tianjia(Article article);
    //修改
    @Update("update article set " +
            "title=#{title}," +

            "content=#{content}," +
            "cover_img=#{cover_img}," +
            "state=#{state}," +
            "category_id=#{category_id}," +
            "create_user=#{create_user} where id=#{id}")
    int xiugai(Article article);
    int batchSaveAccount(List<Article> cache);
}
